<template>
	<div class="discount-yhq">
		<div class="inputsressch">
			<input type="text" placeholder="请输入优惠码"/>
			<span>兑换</span>
		</div>
		<div class="bushiyongbtn" @click="zbshiyong()">暂不使用红包</div>
		<ul class="discount-list">
			<li class="discount-item" v-for="item in hblist" @click="hongbaoplay(item.coupon_sn)">
				<div class="discount-xinxi">
					<h3 v-text="item.coupon_name"></h3>
					<span v-text="item.min_amount>0?item.min_amount:'无门槛'"></span>
					<p>使用期限 <span v-text="item.start_time"></span>-<span v-text="item.end_time"></span></p>
				</div>
				<div class="discount-jine">
					<h3 v-html="'<span>￥</span>'+item.coupon_value"></h3>
					<span v-text="(item.type==1&&item.store_id==0)?'平台红包':'优惠券'"></span>
				</div>
			</li>
		</ul>
		<p class="disfooter">没有更多红包啦~</p>
	</div>
</template>

<script>
	export default{
		name:'playdisthb',
		data () {
			return{
				user:0,
				storeid:0,
				goodsid:0,
				specid:0,
				hblist:[],
				couponsn:''
			}
		},
		created:function(){
			this.user=localStorage.getItem("nt_user");
			this.storeid=this.$route.query.storetoken;
			this.goodsid=this.$route.query.goodstoken;
			this.specid=this.$route.query.spectoken;
			if(this.$route.query.couponsn){
				this.couponsn=this.$route.query.couponsn;
			}
		},
		methods:{
			hongbaoplay:function(sn){
				window.sessionStorage['yhq_sn']=sn;
				window.sessionStorage['yhq_zbsy']=0;
				history.go(-1);
			},
			zbshiyong:function(){
				window.sessionStorage['yhq_sn']='';
				window.sessionStorage['yhq_zbsy']=1;
				history.go(-1);
			}
		},
		mounted:function(){
			var self=this;
			$.ajax({
				type:"get",
				url:furl+"index.php?app=ajax_order&act=privilege",
				data:{'token':self.user,'store_id':self.storeid,'goods_id':self.goodsid,'spec_id':self.specid,'packe_sn':self.couponsn},
				dataType:'json',
				success:function(res){
					if(res.done){
						for(var key in res.retval){
							res.retval[key].end_time=new Date(Number(res.retval[key].end_time)*1000).Format('yyyy.MM.dd');
							res.retval[key].start_time=new Date(Number(res.retval[key].start_time)*1000).Format('yyyy.MM.dd');
							self.hblist.push(res.retval[key]);
							if(res.retval[key].check_cost != 0){
								$("#hblb").css("display","none")
								location.reload();
							}
						}
					}
				}
			});
		}
	}
</script>

<style>
	.discount-yhq{font-size:0;}
	.discount-list{padding-left:0.27rem;padding-right:0.27rem;/*padding-top: 0.38rem;*/}
	.discount-item{background-image:url(../../img-discount/hbbg.png);background-repeat:no-repeat;background-size:100%;position:relative;margin-bottom: 0.16rem;}
	.discount-sy{position:absolute;top:-0.11rem;right:-0.12rem;width:1.1rem;height:0.84rem;}
	.discount-xinxi{display:inline-block;width:4.5rem;height:2.25rem;box-sizing: border-box;padding: 0.4rem 0 0 0.4rem;}
	.discount-xinxi>h3{font-size:0.32rem;color:#2b2b2b;line-height: 0.3rem;margin-bottom: 0.24rem;}
	.discount-xinxi>span{display:inline-block;font-size:0.24rem;color:#4C9D31;line-height: 0.23rem;margin-bottom: 0.39rem;font-weight:600;}
	.discount-xinxi>p{font-size:0.22rem;color:#999;line-height: 0.22rem;}
	.discount-jine{display: inline-block;width:2.3rem;float:right;margin-right: 0.08rem;text-align: center;}
	.discount-jine>h3{font-size:0.5rem;color:#4c9d31;line-height: 0.6rem;margin-bottom: 0.1rem;margin-top: 0.54rem;font-weight:500;margin-right: 0.2rem;}
	.discount-jine>h3>span{font-size:0.4rem;}
	.discount-jine>span{font-size:0.24rem;color:#4C9D31;line-height: 0.24rem;}
	.diacount-shixiao h3,.diacount-shixiao span,.diacount-shixiao p{color:#999 !important;}
	.bushiyongbtn{font-size:0.28rem;color:#999;text-align: center;height:0.88rem;width:6.86rem;margin:1.22rem auto 0.32rem;background-color:#fff;box-shadow: 0 0 0.06rem rgba(75, 147, 5, 0.05);border-radius:0.16rem;line-height: 0.88rem;}
	.disfooter{text-align: center;line-height: 0.8rem;font-size:0.32rem;color:#999;height:0.8rem;}
	.inputsressch{background-color:#fff;position:fixed;top:0;left:0;right:0;height:0.9rem;padding:0.15rem 0.32rem;box-sizing: border-box;}
	.inputsressch>input{width:6rem;height:0.6rem;border-radius:0.3rem;background-color:#EEEEEE;color:#999;font-size:0.24rem;box-sizing: border-box;padding-left: 0.32rem;}
	.inputsressch>span{font-size:0.32rem;color:#4C9D31;float:right;line-height: 0.6rem;display: inline-block;}
</style>